package com.ms.rc_lab.ui.ServoMotor;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import com.ms.rc_lab.HorizontalAdapter;
import com.ms.rc_lab.HorizontalListView;
import com.ms.rc_lab.R;
import com.ms.rc_lab.databinding.FragmentServoBinding;

import java.util.ArrayList;

public class ServoMotorFragment extends Fragment {

    private FragmentServoBinding binding;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        binding = FragmentServoBinding.inflate(inflater, container, false);
        View root = binding.getRoot();

        final HorizontalListView textView = binding.horizontalListView;
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i=0; i<8; i++){
            arrayList.add(String.format("舵机%d", i));
        }

        HorizontalAdapter adapter = new HorizontalAdapter(getContext(), R.layout.motor_item, arrayList, HorizontalAdapter.Mode.MODE_SERVO);
        binding.horizontalListView.setAdapter(adapter);
        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}